package dxunderground.winampController.Server.GUI;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.io.IOException;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.jdom.JDOMException;

import dxunderground.winampController.Common.GUI;
import dxunderground.winampController.Server.PlaylistQueue;

@SuppressWarnings("serial")
public class LoadPanel extends JPanel {
	public static JLabel shuffle = new JLabel("Shuffle: " + PlaylistQueue.auto);

	public LoadPanel(GUI gui, ButtonActions buttonActions) throws JDOMException, IOException {
		this.setLayout(new BorderLayout());
		gui.loadField = new JTextField(60);
		gui.loadField.setText(buttonActions.readLoad());

		JButton browseButton = new JButton("Browse");
		browseButton.addActionListener(buttonActions);
		JButton loadButton = new JButton("Load");
		loadButton.addActionListener(buttonActions);
		JButton clearButton = new JButton("Clear");
		clearButton.addActionListener(buttonActions);
		JButton autoButton = new JButton("Auto Shuffle");
		autoButton.addActionListener(buttonActions);

		JPanel buttonPanel = new JPanel(new GridLayout(2, 2));
		JPanel fieldPanel = new JPanel(new GridLayout(2, 1));
		fieldPanel.add(gui.loadField);
		fieldPanel.add(shuffle);

		this.add(fieldPanel, BorderLayout.CENTER);
		buttonPanel.add(browseButton);
		buttonPanel.add(loadButton);
		buttonPanel.add(clearButton);
		buttonPanel.add(autoButton);
		this.add(buttonPanel, BorderLayout.EAST);
	}
}
